package srzy.driver

import srzy.common.Logging
import srzy.socket.MsgActor
import srzy.module.CaseDeal
import srzy.rb.RBMsg

object Start extends srzy.common.Logging {

  def main(args: Array[String]): Unit = {
    deal
  }

  def deal2 = {

    val receMsg = "[000=CCG001.chinatelecom.com:50000;353120002;456][001=00120080808195950000253088][003=0][EVT=10129][R60=000,R601=0,R611=0][B10=000,B100=1,B106=3,B107=1024][B03=000,B030=1,B035=-1,B036=2,B037=0][B01=000,B010=1,B015=-1,B016=2,B017=0][B20=000,B201=0,B202=3,B203=1024,B204=0][B21=000,B211=-1,B212=2,B213=10000][B06=000,B061=h51,B062=4,B063=1024,B064=1024;B06=000,B061=h54,B062=4,B063=1024,B064=1024][B07=000,B071=155111,B072=0][B08=000,B081=15511,B082=2,B083=0,B084=10000,B085=19919,B086=-1][B22=000,B221=02,B222=100352]}{[100=81][101=20150522094005632][000=CCG001.chinatelecom.com:50000;353120002;123][001=00120080808195950000253088][003=0][EVT=10129][R60=000,R601=0,R611=0][B10=000,B100=2000,B106=3,B107=1024][B03=000,B030=2000,B035=-1,B036=2,B037=0][B01=000,B010=2000,B015=-1,B016=2,B017=0][B20=000,B201=0,B202=3,B203=1024,B204=0][B21=000,B211=-1,B212=2,B213=10000][B06=000,B061=h51,B062=4,B063=1024,B064=2048;B06=000,B061=h54,B062=4,B063=1024,B064=2048][B07=000,B071=155111,B072=0][B08=000,B081=15511,B082=2,B083=0,B084=10000,B085=19919,B086=-1][B22=000,B221=02,B222=99328]}"
    val receStdMsg = "{[100=81][101=20150521173241081][000=CCG001.chinatelecom.com:50000;353120002;456][001=00120080808195950000253088][003=0][EVT=10129][R60=000,R601=0,R611=0][B10=000,B100=1,B106=3,B107=1024][B03=000,B030=1,B035=-1,B036=2,B037=0][B01=000,B010=1,B015=-1,B016=2,B017=0][B20=000,B201=0,B202=3,B203=1024,B204=0][B21=000,B211=-1,B212=2,B213=10000][B06=000,B061=h51,B062=4,B063=1024,B064=1024;B06=000,B061=h54,B062=4,B063=1024,B064=1024][B07=000,B071=155111,B072=0][B08=000,B081=15511,B082=2,B083=0,B084=10000,B085=19919,B086=-1][B22=000,B221=02,B222=100352]}{[100=81][101=20150521173924525][000=CCG001.chinatelecom.com:50000;353120002;123][001=00120080808195950000253088][003=0][EVT=10129][R60=000,R601=0,R611=0][B10=000,B100=2000,B106=3,B107=1024][B03=000,B030=2000,B035=-1,B036=2,B037=0][B01=000,B010=2000,B015=-1,B016=2,B017=0][B20=000,B201=0,B202=3,B203=1024,B204=0][B21=000,B211=-1,B212=2,B213=10000][B06=000,B061=h51,B062=4,B063=1024,B064=2048;B06=000,B061=h54,B062=4,B063=1024,B064=2048][B07=000,B071=155111,B072=0][B08=000,B081=15511,B082=2,B083=0,B084=10000,B085=19919,B086=-1][B22=000,B221=02,B222=99328]}"

    val (res, compLog) = RBMsg.compare2(receMsg, receStdMsg)

    logger.debug("res:" + res)
    logger.debug("compLog:" + compLog)
  }
  //  def deal1 = {
  //
  //    val filterList = List("100", "101", "001")
  //
  //    def filterMsg(s: String) = filterList.foldLeft(s)((e, q) => {
  //      val r1 = ("""\[""" + q + """=[\p{Graph}]+?\]""").r
  //      r1.replaceAllIn(e, "")
  //    })
  //
  //    val std1 = "[000=CCG001.chinatelecom.com:50000;353120002;456][001=00120080808195950000253088][003=0][EVT=10129][R60=000,R601=0,R611=0][B10=000,B100=1,B106=3,B107=1024][B03=000,B030=1,B035=-1,B036=2,B037=0][B01=000,B010=1,B015=-1,B016=2,B017=0][B20=000,B201=0,B202=3,B203=1024,B204=0][B21=000,B211=-1,B212=2,B213=10000][B06=000,B061=h51,B062=4,B063=1024,B064=1024;B06=000,B061=h54,B062=4,B063=1024,B064=1024][B07=000,B071=155111,B072=0][B08=000,B081=15511,B082=2,B083=0,B084=10000,B085=19919,B086=-1][B22=000,B221=02,B222=100352]}{[100=81][101=20150522094005632][000=CCG001.chinatelecom.com:50000;353120002;123][001=00120080808195950000253088][003=0][EVT=10129][R60=000,R601=0,R611=0][B10=000,B100=2000,B106=3,B107=1024][B03=000,B030=2000,B035=-1,B036=2,B037=0][B01=000,B010=2000,B015=-1,B016=2,B017=0][B20=000,B201=0,B202=3,B203=1024,B204=0][B21=000,B211=-1,B212=2,B213=10000][B06=000,B061=h51,B062=4,B063=1024,B064=2048;B06=000,B061=h54,B062=4,B063=1024,B064=2048][B07=000,B071=155111,B072=0][B08=000,B081=15511,B082=2,B083=0,B084=10000,B085=19919,B086=-1][B22=000,B221=02,B222=99328]}"
  //    val std2 = "{[100=81][101=20150521173241081][000=CCG001.chinatelecom.com:50000;353120002;456][001=00120080808195950000253088][003=0][EVT=10129][R60=000,R601=0,R611=0][B10=000,B100=1,B106=3,B107=1024][B03=000,B030=1,B035=-1,B036=2,B037=0][B01=000,B010=1,B015=-1,B016=2,B017=0][B20=000,B201=0,B202=3,B203=1024,B204=0][B21=000,B211=-1,B212=2,B213=10000][B06=000,B061=h51,B062=4,B063=1024,B064=1024;B06=000,B061=h54,B062=4,B063=1024,B064=1024][B07=000,B071=155111,B072=0][B08=000,B081=15511,B082=2,B083=0,B084=10000,B085=19919,B086=-1][B22=000,B221=02,B222=100352]}{[100=81][101=20150521173924525][000=CCG001.chinatelecom.com:50000;353120002;123][001=00120080808195950000253088][003=0][EVT=10129][R60=000,R601=0,R611=0][B10=000,B100=2000,B106=3,B107=1024][B03=000,B030=2000,B035=-1,B036=2,B037=0][B01=000,B010=2000,B015=-1,B016=2,B017=0][B20=000,B201=0,B202=3,B203=1024,B204=0][B21=000,B211=-1,B212=2,B213=10000][B06=000,B061=h51,B062=4,B063=1024,B064=2048;B06=000,B061=h54,B062=4,B063=1024,B064=2048][B07=000,B071=155111,B072=0][B08=000,B081=15511,B082=2,B083=0,B084=10000,B085=19919,B086=-1][B22=000,B221=02,B222=99328]}"
  //
  //    val receStd1 = new RBMsgFullParser(filterMsg(std1))
  //    val receStd2 = new RBMsgFullParser(filterMsg(std2))
  //    val l = receStd1.equals(receStd2)
  //    println(l)
  //    println(receStd1.getCompLog())
  //  }

  def deal = {
    try {
      MsgActor.start
      CaseDeal.dealAllCase
      (MsgActor !! 'exit).apply
      logger.debug("aplication run over")
    } catch {
      case ex: Exception => {
        logger.error(ex.getMessage(), ex)
        sys.exit
      }
    }

  }

}
